import {renderAceEditor} from './ace'

let _outputHtml = ''

renderAceEditor('codeeditor', '')
document.getElementById('appCodeCopy').addEventListener('click', function () {
  window.navigator.clipboard.writeText(_outputHtml)
  window.XyMessage.info('copied')
})

window.toggleAppCodeModal = function (isShow, options = {}) {
  let appCodeModal = document.getElementById('appCodeModal')

  if (isShow) {
    appCodeModal.style.display = 'block'
    if (options && options.content) {
      renderAceEditor('codeeditor', options.content)
      _outputHtml = options.content
    }
  } else {
    appCodeModal.style.display = 'none'
  }
}
